Filter module based on Section Number (Object Number)

Hello guys,

This is my first post in this forum :-D

I have seen a few threads in this forum about the use of Object Number.
I have a need to filter the module based on the section number (Object Number).

For example, if I only need to filter the section "3.1", I do not want the filtered display set to include objects of section "3.10", "3.11", etc.

So, I wrote the following code:
 

string objNo = "3.1"
int noOfChars = length objNo
 
// Validate only the last character to ensure that it is a number.
if( ((intOf objNo[noOfChars-1]) < 48 ) || ((intOf objNo[noOfChars-1]) > 57 ) )
{
    ack "Invalid section number: Shall end only with a number !"
        halt
}
 
Object othero = null
string s = null
 
filtering off
 
for othero in current Module do
{
        s = probeAttr_(othero,"Object Number")
 
        if( (s[0:(noOfChars-1)] == objNo) && ( (s[noOfChars:noOfChars] == "") || (s[noOfChars:noOfChars] == ".") || (s[noOfChars:noOfChars] == "-") ) )
                accept othero
        else
                reject othero
}
 
filtering on

 


The code works fine for all cases that I know of.
However, I feel there should be a better, more efficient way of doing the same thing.

I would be glad if you guys can give me your comments / suggestion to improve the code.

 


bullbala - Wed Feb 16 04:52:41 EST 2011